
using System;

namespace GraphSpace
{
	public class Knoten
	{
		private int id;
		private double daten;

		// Attribute für Algorithmen
		private bool flag;
		// Flag zum Markieren des Knotens
		private int d_time;
		// Zeitpunkt der Entdeckung beim Graph-Scanning
		private int f_time;
		// Zeitpunkt der Abarbeitung beim Graph-Scanning
		private int current;
		// Zeiger auf eine ausgehende Kante (wichtig für Tiefensuche)
		private int pred;
		// Zeiger auf den Vorgänger Knoten beim Graph-Scanning
		public Knoten ()
		{
			this.id = 0;
			this.daten = 0.0;
			this.flag = false;
			this.d_time = 0;
			this.f_time = 0;
			this.current = 0;
			this.pred = 0;
		}

		public Knoten (int id, double daten)
		{
			this.id = id;
			this.daten = daten;
			
			this.flag = false;
			this.d_time = 0;
			this.f_time = 0;
			this.current = 0;
			this.pred = 0;
		}

		public void init (int id, double daten)
		{
			this.id = id;
			this.daten = daten;
			
			this.flag = false;
			this.d_time = 0;
			this.f_time = 0;
			this.current = 0;
			this.pred = 0;
		}

		// setzt die Attribute für Algorithmen auf ihre Standardwerte zurück
		public void reset ()
		{
			this.flag = false;
			this.d_time = 0;
			this.f_time = 0;
			this.current = 0;
			this.pred = 0;
		}

		public int Id {
			get { return this.id; }
		}
		public double Daten {
			get { return this.daten; }
			set { this.daten = value; }
		}
		public bool Flag {
			get { return this.flag; }
			set { this.flag = value; }
		}
		public int D_time {
			get { return this.d_time; }
			set { this.d_time = value; }
		}
		public int F_time {
			get { return this.f_time; }
			set { this.f_time = value; }
		}
		public int Current {
			get { return this.current; }
			set { this.current = value; }
		}
		public int Pred {
			get { return this.pred; }
			set { this.pred = value; }
		}
	}
	
	public class DijkstraKnoten : Knoten, IKey
    {
        public int HeapPos;
        public double distance;
        public Knoten predeseccor;
        public bool besucht;

        public DijkstraKnoten(int id, double daten, int Distance, DijkstraKnoten Predeseccor) :
            base(id, daten)
        {
            distance = Distance;
            predeseccor = Predeseccor;
            besucht = false;
            HeapPos = 0;
        }

        public double getKey()
        {
            return distance;
        }

        public void setKey(double Key)
        {
            distance = Key;
        }

        public int getHeapPos()
        {
            return HeapPos;
        }

        public void setHeapPos(int Pos)
        {
            HeapPos = Pos;
        }
    }
	
	public class BiDijkstraKnoten : DijkstraKnoten, IKey
	{
		public int HeapPos2;
		public double distance2;
		public Knoten predeseccor2;
		public bool besucht2;

		public BiDijkstraKnoten (int id, double daten, int Distance1, DijkstraKnoten Predeseccor1, int Distance2, DijkstraKnoten Predeseccor2) : base(id, daten, Distance1, Predeseccor1)
		{
			distance2 = Distance2;
			predeseccor2 = Predeseccor2;
			besucht2 = false;
			HeapPos2 = 0;
		}

		public double getKey2 ()
		{
			return distance2;
		}

		public void setKey2 (double Key)
		{
			distance2 = Key;
		}

		public int getHeapPos2 ()
		{
			return HeapPos2;
		}

		public void setHeapPos2 (int Pos)
		{
			HeapPos2 = Pos;
		}
	}
	
	public class AStarNode : DijkstraKnoten
	{
		public double realdist;
		public int x;
		public int y;

		public AStarNode (int id, double daten, int Distance, AStarNode Predeseccor, int X, int Y) : base(id, daten, Distance, Predeseccor)
		{
			x = X;
			y = Y;
		}
	}
}
